#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    int numWaterBottles(int numBottles, int numExchange) {
        int count = 0;
        int n = 0;

        while (numBottles-- > 0)
        {
            ++n;
            ++count;
            if (count == numExchange)
            {
                ++numBottles;
                count = 0;
            }
        }

        return n;
    }
};